package com.netkit;

import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.Channels;

public class NetkitChannelPipelineFactory implements ChannelPipelineFactory{
	public static final String EncodeHandlerName = "encoder";
	public static final String DecodeHandlerName = "decoder";
	public static final String MessageHandlerName = "handler";

	private final NetkitContext context;

	public NetkitChannelPipelineFactory(final NetkitContext context){
		this.context = context;
	}
	

	@Override
	public ChannelPipeline getPipeline() throws Exception {
		ChannelPipeline pipeline = Channels.pipeline();
		pipeline.addLast(DecodeHandlerName, new NetkitProtocolDecoder());
		pipeline.addLast(EncodeHandlerName, new NetkitProtocolEncoder());
		pipeline.addLast(MessageHandlerName, new NetkitChannelHandler(context));
		return pipeline;
	}

}
